<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<script type="text/javascript">
	function reportView(no) {
		$("#reportSelectView").show();
		$.ajax({
			type:"post",
			url:"reportSelectList.inven",
			dataType:"json",
			data:"no="+no,
			success:function(data){
				var table = "";
				$.each(data, function(index, value){
					table += "<tr><td>"+value.no +"</td>"+
							 "<td>"+value.title +"</td>"+
							 "<td>"+value.id+"</td>+"+
							 "<td>"+value.reportContent+"</td>"+
							 "<td>"+value.reporter+"</td></tr>"; 
				}); // each
				// tbody 에 테이블을 출력한다.
				$("#reportViewTb").html(table);
			} // success
		}); // ajax
	}
</script>

<h1>신고 리스트 보기</h1>
<table border="1">
	<tr>
		<td>글번호</td>
		<td>총 신고횟수</td>
		<td>신고 내역 보기</td>
	</tr>

<c:choose>
	<c:when test="${fn:length(requestScope.list)!=0 }">
	<c:forEach items="${requestScope.list }" var="allReportCount">
		<tr>
			<td>${allReportCount.no }</td>
			<td>${allReportCount.allCount }</td>
			<td><a href="javascript:reportView(${allReportCount.no })">보기</a></td>
		</tr>
	</c:forEach>
	</c:when>
		
	<c:otherwise>
		<tr>
			<td colspan="3"><p>신고 내역이 존재하지 않습니다.</p></td>
		</tr>
	</c:otherwise>
</c:choose>
</table>
<br><br>
<h3>신고 상세 리스트 보기</h3>
<div id="reportSelectView" style="display: none;">
<table border="1">
	<tr>
		<td>번호</td>
		<td>글제목</td>
		<td>글쓴이</td>
		<td>신고내용</td>
		<td>신고자</td>
	</tr>
	<tbody id="reportViewTb">
		<%-- <c:forEach items="${requestScope.selectList }" var="report">
		<tr>
			<td>${report.no }</td>
			<td>${report.title }</td>
			<td>${report.id }</td>
			<td>${report.reportContent }</td>
			<td>${report.reporter }</td>
		</tr>
		</c:forEach> --%>
	</tbody>
</table>
</div>